import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '../views/Home.vue';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect: '/main',
    children: [
      {
        path: '/main',
        name: 'Main',
        component: () => import('../views/Main.vue'),
        
      },
      {
        path: '/service',
        name: 'Service',
        redirect: '/legacy',
        component: () => import('../views/Service.vue'),
        children: [
          {
            path: '/legacy',
            component: () => import('../components/Service/Legacy.vue'),
          },
          {
            path: '/cliam',
            component: () => import('../components/Service/Claim.vue'),
          },
          {
            path: '/receipt',
            component: () => import('../components/Service/Receipt.vue'),
          },
          {
            path: '/specialcase',
            component: () => import('../components/Service/SpecialCase.vue'),
          },
          {
            path: '/seat',
            component: () => import('../views/SeatSelection.vue'),
          },
        ],
      },
      {
        path: '/guide',
        name: 'Guide',
        redirect: '/customerservice',
        component: () => import('../views/Guide.vue'),
        children: [
          {
            path: '/customerservice',
            component: () => import('../components/Guide/CustomerService.vue'),
          },
          {
            path: '/illustrate',
            component: () => import('../components/Guide/Illustrate.vue'),
          },
          {
            path: '/insuranceClause1',
            component: () =>
              import('../components/Guide/Help/InsuranceClause1.vue'),
          },
          {
            path: '/insuranceClause2',
            component: () =>
              import('../components/Guide/Help/InsuranceClause2.vue'),
          },
          {
            path: '/passengerClause',
            component: () =>
              import('../components/Guide/Help/PassengerClause.vue'),
          },
        ],
      },
      {
        path: '/info',
        name: 'Info',
        redirect: '/personinfo',
        component: () => import('../views/Info.vue'),
        children: [
          {
            path: '/personinfo',
            component: () => import('../components/Info/Person/Personinfo.vue'),
          },
          {
            path: '/allorder',
            component: () => import('../components/Info/order/allorder.vue'),
          },
          {
            path: '/vip',
            component: () => import('../components/Info/VIP/VIP.vue'),
          },
          {
            path: '/credit',
            component: () => import('../components/Info/Credit/Credit.vue'),
          },
        ],
      },
      {
        path: '/booking',
        name: 'Book',
        component: () => import('../views/Booking.vue'),
      },
    ],
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue'),
  },
  {
    path: '/findPassword',
    name: 'FindPassword',
    component: () => import('../views/FindPassword.vue'),
  },
  {
    path: '/buyTicket',
    name: 'BuyTicket',
    component: () => import('../views/BuyTicket.vue'),
  },
  {
    path: '/admin',
    name: 'Admin',
    component: () => import('../views/Admin/Index.vue'),
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'DashBoard',
        component: () => import('../views/Admin/DashBoard.vue'),
      },
      {
        path: '/user',
        name: 'User',
        component: () => import('../views/Admin/User.vue'),
      },
      {
        path: '/order',
        name: 'Order',
        component: () => import('../views/Admin/Order.vue'),
      },
      {
        path: '/flight',
        name: 'Flight',
        component: () => import('../views/Admin/Flight.vue'),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
